package com.bangcommunity.bbframe.mq;

/**
 * Created by tanghc on 17/2/3.
 */

import com.bangcommunity.bbframe.common.utils.thread.CommonThreadPoolManager;
import com.bangcommunity.bbframe.mq.consumer.IQtMsgProcessor;
import com.bangcommunity.bbframe.mq.consumer.QtConsumerClient;
import com.bangcommunity.bbframe.test.common.TestUtil;

import java.util.Properties;

public class QtKafkaConsumerExample {
    public static void main(String[] args) throws InterruptedException {
        CommonThreadPoolManager.getInstance()
                .addThread(QtConsumerClient.builderConsumer("qtuc", "basedata", "t1", new IQtMsgProcessor<String>() {
                    @Override
                    public void onConsume(String msgId, String o) {
                        System.out.println("1=============:" + msgId + ":" + o);
                    }
                }));
        CommonThreadPoolManager.getInstance()
                .addThread(QtConsumerClient.builderConsumer("qtuc", "basedata", "t1", new IQtMsgProcessor<Integer>() {
                    @Override
                    public void onConsume(String msgId, Integer o) {
                        System.out.println("2=============:" + msgId + ":" + o);
                    }
                }));
        Properties properties = new Properties();
        properties.setProperty("group.id", "test1");
        CommonThreadPoolManager.getInstance().addThread(
                QtConsumerClient.builderConsumer("qtuc", "basedata", "t1", properties, new IQtMsgProcessor<Long>() {
                    @Override
                    public void onConsume(String msgId, Long o) {
                        System.out.println("3=============:" + msgId + ":" + o);
                    }
                }));
        TestUtil.waitForInput();
    }

}